import java.io.IOException;
import java.io.Reader;

import org.antlr.runtime.ANTLRReaderStream;
import org.antlr.runtime.CharStream;


public class ANTLRCaseInsensitiveReaderStream extends ANTLRReaderStream {
	
	public ANTLRCaseInsensitiveReaderStream(Reader r) throws IOException {
		super(r);
	}

	public int LA(int i) {
	        if ( i==0 ) {
	            return 0; // undefined
	        }
	        if ( i<0 ) {
	            i++; // e.g., translate LA(-1) to use offset 0
	        }

	        if ( (p+i-1) >= n ) {

	            return CharStream.EOF;
	        }
	        
	        if(data[p+i-1]>64 && data[p+i-1]<91) {
	        	return Character.toLowerCase(data[p+i-1]);
	        }
	        
	        if(data[p+i-1]==9) {
	        	return 32;
	        }
	        
	        return data[p+i-1];
	    }

}
